Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up exceptions and split FileFormatError in LoadError and DumpError #345

Merged
merged 3 commits into from
Jun 21, 2024

Conversation

tovrstra
Copy link
Member

@tovrstra tovrstra commented Jun 21, 2024

This fixes a task in #191: splitting FileFormatError and FileFormatWarning into Load... and Dump... versions, and fix formats that raise various generic exceptions. There is still a FileFormatError, but it is only used for errors related to identifying or selecting the correct file format. This fix will make error messages more informative in general, and it will make the original goal of #191 easier to achieve.

Note that there are a few more tasks related to exception handling in #191, not included in this PR, to keep it small. Cleanups like these quickly become large, so I've suppressed the usual oh-I-can-also-fix-this reflex and deferred these to future PRs instead.

I will YOLO-merge this on June 28 unless reviewed earlier.

Summary by Sourcery

Refactored exception handling to provide more specific error types for loading and dumping operations, and updated corresponding test cases.

  • Enhancements:
    • Refactored exception handling by splitting FileFormatError and FileFormatWarning into LoadError, LoadWarning, DumpError, and DumpWarning for more specific error categorization.
  • Tests:
    • Updated test cases to use LoadWarning and LoadError instead of FileFormatWarning and FileFormatError.

Copy link
Contributor

sourcery-ai bot commented Jun 21, 2024

Reviewer's Guide by Sourcery

This pull request addresses a task from issue #191 by splitting the FileFormatError and FileFormatWarning into more specific LoadError, LoadWarning, DumpError, and DumpWarning classes. The changes aim to make error messages more informative and specific to the context of loading or dumping data. The FileFormatError is retained but is now only used for errors related to identifying or selecting the correct file format. The changes also include updating the exception handling in various modules and tests to use the new error classes.

File-Level Changes

Files Changes
iodata/formats/json.py
iodata/api.py
iodata/utils.py
iodata/test/test_json.py
iodata/formats/mwfn.py
iodata/test/test_cp2klog.py
iodata/formats/pdb.py
iodata/test/test_pdb.py
iodata/formats/gromacs.py
iodata/formats/fchk.py
iodata/formats/mol2.py
iodata/formats/molden.py
iodata/formats/molekel.py
iodata/test/common.py
iodata/test/test_wfx.py
iodata/test/test_api.py
iodata/test/test_inputs.py
iodata/test/test_sdf.py
iodata/formats/gamess.py
iodata/formats/gaussianinput.py
iodata/test/test_mol2.py
Replaced FileFormatError and FileFormatWarning with more specific LoadError, LoadWarning, DumpError, and DumpWarning classes. Updated exception handling in various modules and tests to use the new error classes.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

deepsource-io bot commented Jun 21, 2024

Here's the code health analysis summary for commits 3f2e4fc..cfbbceb. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource Shell LogoShell✅ SuccessView Check ↗
DeepSource Python LogoPython✅ Success
🎯 2 occurences resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tovrstra - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

iodata/api.py Show resolved Hide resolved
iodata/api.py Outdated Show resolved Hide resolved
iodata/utils.py Show resolved Hide resolved
iodata/test/test_json.py Show resolved Hide resolved
Copy link
Member

@PaulWAyers PaulWAyers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through it quickly and it seems OK.

@tovrstra
Copy link
Member Author

Thanks for checking, Paul.

I've also double-checked it, but could not spot obvious mistakes. The critical parts will be revisited in future pull requests, so I'll be taking a second look in any case.

@tovrstra tovrstra merged commit be722a9 into theochem:main Jun 21, 2024
12 checks passed
@tovrstra tovrstra deleted the format-exceptions branch June 21, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants